<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <title>函数式组件</title>
  <script src="./js/react.development.js"></script>
  <script src="./js/react-dom.development.js"></script>
  <script src="./js/babel.min.js"></script>
  <style>
    header {
      height: 100px;
      background-color: #aef;
    }

    main {
      height: 350px;
      background-color: #ceb;
    }

    footer {
      height: 100px;
      background-color: #fea;
    }
  </style>
</head>

<body>
  <div id="root"></div>
  <script type="text/babel">
    //声明一个函数组件
    function Header() {
      return <header></header>;
    }

    function Main() {
      return <main></main>;
    }

    function Footer() {
      return <footer></footer>
    }

    //创建虚拟 DOM 对象
    //声明一个组件函数
    function App() {
      return <div>
        {/*该组件标签在渲染的时候, 会调用同名函数, 获得对应的虚拟 DOM 对象*/}
        <Header></Header>
        <Main />
        <Footer />
      </div>
    }

    //渲染
    ReactDOM.render(<App />, document.querySelector('#root'));
  </script>
</body>

</html>